<?php
/* @var $this MatchController */
/* @var $dataProvider CActiveDataProvider */

$roundStatic = array(
		'1-7'     => '1-7',
		'8-14'     => '8-14',
		'15-21'     => '15-21',
		'22-28'     => '22-28',
		'29-35'     => '29-35',
		'36-42'     => '36-42',
		'43-49'     => '43-49',
		'50-56'     => '50-56',
		'57-63'     => '57-63',
);




$this->widget('zii.widgets.grid.CGridView', array(

		'dataProvider'=>$model->search(),
		'filter'=>$model,
		'cssFile'=>Yii::app()->request->baseUrl.'/css/cgridview.css',
		'columns'=>array(
					
				array(
						'header'=>Yii::t("isml_match","year"),
						'name'=>'YEAR',
						'value'=>'Yii::t("isml_name","$data->YEAR")',
						'htmlOptions'=>array('width'=>'80px'),
						'filter' =>CHtml::listData($model->findAll(array("order"=>'YEAR DESC')), 'YEAR', 'YEAR'),

				),
				array(
						'header'=>Yii::t("isml_match","round"),
						'name'=>'ROUND',
						'value'=>'Yii::t("isml_name","$data->ROUND")',

						'filter' => $roundStatic+CHtml::listData(
								is_numeric($model->YEAR) ? Match::model()->findAll(new CDbCriteria(array(
										'condition' => 'YEAR= :YEAR',
										'params' => array(':YEAR' => $model->YEAR),
										'order'=>'ROUND'
								))) : Match::model()->findAll(array('order'=>'ROUND')), 'ROUND', 'ROUND'),
						'htmlOptions'=>array('width'=>'60px'),
				),
				array(
						'header'=>Yii::t("isml_match","type"),
						'name'=>'TYPE',
						'value'=>'Yii::t("isml_match","$data->TYPE")',
						'filter'=>array(
								'Stella'=>Yii::t("isml_match","Stella"),
								'Nova'=>Yii::t("isml_match","Nova"),
								'None'=>Yii::t("isml_match","None"),),
						'htmlOptions'=>array('width'=>'60px'),

				),


				array(
						'header'=>Yii::t("isml_match","name"),
						'name'=>'NAME',
						'value'=>'Yii::t("isml_name","$data->NAME")',
						'htmlOptions'=>array('width'=>'150px'),

						'filter' => CHtml::listData(
								is_numeric($model->YEAR) ? Match::model()->findAll(new CDbCriteria(array(
										'condition' => 'YEAR= :YEAR',
										'params' => array(':YEAR' => $model->YEAR),
								))) : Match::model()->findAll(array('order'=>'NAME')), 'NAME', 'nameLocalized'),


				),
				array(
						'header'=>Yii::t("isml_match","vote"),
						'name'=>'VOTE',
						'value'=>'Yii::t("isml_name","$data->VOTE")',
						'htmlOptions'=>array('width'=>'60px'),
						'filterHtmlOptions' => array('style' => 'visibility:hidden'),
						'htmlOptions'=>array('width'=>'60px'),
				),
				array(
						'header'=>Yii::t("isml_match","oname"),
						'name'=>'O_NAME',
						'value'=>'Yii::t("isml_name","$data->O_NAME")',
						'htmlOptions'=>array('width'=>'150px'),
						'filter' => CHtml::listData(
								is_numeric($model->YEAR) ? Match::model()->findAll(new CDbCriteria(array(
										'condition' => 'YEAR= :YEAR',
										'params' => array(':YEAR' => $model->YEAR),
								))) : Match::model()->findAll(array('order'=>'NAME')), 'NAME', 'nameLocalized'),
				),

				array(
						'header'=>Yii::t("isml_match","ovote"),
						'name'=>'O_VOTE',
						'value'=>'Yii::t("isml_name","$data->O_VOTE")',
						'filter' => array(
								'Misaka Mikoto'=>'御坂美琴',
								'2'=>'2',),
						'htmlOptions'=>array('width'=>'60px'),
						'filterHtmlOptions' => array('style' => 'visibility:hidden'),
				),

				array(
						'header'=>Yii::t("isml_match","tvote"),
						'name'=>'T_VOTE',
						'value'=>'Yii::t("isml_name","$data->T_VOTE")',
						'htmlOptions'=>array('width'=>'60px'),
						'filterHtmlOptions' => array('style' => 'visibility:hidden'),
				),

				array(
						'header'=>Yii::t("isml_match","dvote"),
						'name'=>'D_VOTE',
						'value'=>'Yii::t("isml_name","$data->D_VOTE")',
						'filter' => array(
								'>0' => Yii::t("isml_match","win"),
								'=0' => Yii::t("isml_match","draw"),
								'<0' => Yii::t("isml_match","lose"),),
						'htmlOptions'=>array(
								'width'=>'100px'
						),

// 						'cssClassExpression'=> '"diff".(int)($data->D_VOTE/2000)',


				),

				array(
						'header'=>Yii::t("isml_match","pvote"),
						'name'=>'P_VOTE',
						'value'=>'Yii::app()->numberFormatter->formatPercentage($data->P_VOTE)',
						'htmlOptions'=>array('width'=>'100px'),
						'filterHtmlOptions' => array('style' => 'visibility:hidden'),
				),

		)

));
?>